import React from 'react';
import { Routes, Route, Navigate } from 'react-router-dom';
import routes from './routes';

function App() {
    return (
        <>
            <h1>App2</h1>
            <div>
                <React.Suspense fallback={<div>Loading...</div>}>
                    <Routes>
                        {
                            routes.map(({ path, component: Comp }) => (
                                <Route
                                    key={path}
                                    path={path}
                                    element={<Comp />}
                                />
                            ))
                        }
                        <Route path="*" element={<Navigate to={routes[0].path} replace />} />
                    </Routes>
                </React.Suspense>
            </div>
        </>
    );
}

export default App;
